package com.qmsign.project.controller.user;


import com.qmsign.project.model.User;
import com.qmsign.project.service.IUserService;
import com.qmsign.project.utils.IdWorker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-09-15
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService userService;
    private static final Logger log =  LoggerFactory.getLogger(UserController.class);
    @ResponseBody
    @RequestMapping("login")
    public User getUser(){
        log.info("进入此方法");
        return userService.getById("1");

    }

    @ResponseBody
    @RequestMapping("add")
    public String addUser(){
        User user = new User();
       user.setId(IdWorker.getSnowId());
        user.setPhone("18208182147");
        user.setRealname("lixiaohu");
        user.setIdCard("1234");
        user.setUsername("lixiaohu");
        user.setPassword("123456");
        userService.save(user);
        return "ok";
    }

}
